import { http } from '@/apis/http';
import { ApiResponse } from '@/apis/types/Response';
import { File } from '@/apis/types/File'

export const fileApi = {
    upload(file: File, categoryId: number) {//上传文件   categoryId为 -1->其他上传  0->用户上传  其他->内容上传
        return http.post<ApiResponse<File>>('/ability/file/upload', {
            file,
            categoryId
        }, {
            headers: {
                'Content-Type': 'multipart/form-data'
            }
        });
    },
    getUrl(fileName: string) {
        return http.get<ApiResponse<string>>(`/ability/file/getUrl`, { params: { fileName } });
    },
    deleteObject(fileNames: string[]) {
        return http.post<ApiResponse<null>>(`/ability/file/deleteObject`, {
            fileNames
        });
    }
}
